package com.lccviolet;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * @author LiChaochao
 * @Date 2021/10/7 15:00
 * @Description LockSupportDemo
 */
public class LockSupportDemo {

    public static void main(String[] args) {
        Thread a = new Thread(() -> {
            try { TimeUnit.SECONDS.sleep(3); } catch (InterruptedException e) { e.printStackTrace(); }

            System.out.println(Thread.currentThread().getName() + "......come in");
            LockSupport.park();
            System.out.println(Thread.currentThread().getName() + "......被唤醒");
        }, "a");
        a.start();


        Thread b = new Thread(() -> {
            LockSupport.unpark(a);
            System.out.println(Thread.currentThread().getName() + "......通知");
        }, "b");
        b.start();
    }
}
